<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link type="text/css" rel="stylesheet" href="css/login.css"/>
    <script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="js/login.js"></script>
    <title>登录</title>
</head>

<body>
<div class="header">
    <div class="mainwarp">
        <div class="logo"><a href="index.jsp"><img src="images/log.png"/></a></div>
        <div class="welcome">欢迎登录</div>
        <div class="headerright">
            <a href="index.jsp">返回首页</a>
        </div>
    </div>
</div>
<div class="content">
    <div class="logtype"></div>
    <div class="clear"></div>
    <div class="logoDiv">
        <div class="logoLeft">
            <div class="leftimg">
                <img src="images/log1.gif"/>
            </div>
            <div class="leftcon">
                <a href="" class="a1">手机触屏版</a>
                <a href="" class="a2">Android客户端下载</a>
                <a href="" class="a3">iPhone客户端下载</a>
            </div>
        </div>
        <div class="logoRight">
            <div class="normalLogin">
                <div class="username">
                    <span></span>
                    <input id="userAccount" name="" type="text" placeholder="请输入用户名/邮箱/已验证手机号"/>
                </div>
                <div class="password">
                    <span></span>
                    <input id="upassword" name="" type="text" placeholder="请输入密码"/>
                </div>
                <div class="autoLogo">
                    <a href="password.jsp" class="pasd">忘记密码？</a>
                </div>
                <div class="autoLogo">
                    <span class="CheckBox Yes"></span>
                    <span>我已阅读并接受<a href="user_agreement.jsp">用户协议</a></span>
                </div>
                <div id="loginButton" class="logobtn">
                    <a>登 录</a>
                </div>
                <div class="zcbtn">
                    <a href="register.jsp">还没有账号？立即注册</a>
                </div>
            </div>
            <div class="weixinLogin">
                <div class="weixinQr">
                    <img src="images/showqrcode.jpg" width="150" class="useHelpcon"/>
                    <p>使用微信扫描上方二维码</p>
                    <p class="useHelp useHelpcon">使用帮助</p>
                </div>
                <div class="zcbtn">
                    <a href="register.jsp">还没有账号？立即注册</a>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="clear"></div>
</body>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript">


    var regemial = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");
    var regphone = new RegExp("^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-9])|(18[0-9])|166|198|199|191|(147))\\d{8}$");
    $(document).ready(function () {
        $("[id='loginButton']").click(function () {
            var uname = "";
            var uphone = "";
            var uemail = "";
            var NameEmailPhone = $("[id='userAccount']").val();
            var upassword = $("[id='upassword']").val();
            if (NameEmailPhone != null && upassword != null) {
                if (regphone.test(NameEmailPhone)) {
                    uphone = NameEmailPhone;
                } else if (regemial.test(NameEmailPhone)) {
                    uemail = NameEmailPhone
                } else {
                    uname = NameEmailPhone;
                }
                $.get("loginCheckUser.do",
                    "uname=" + uname +
                    "&uphone=" + uphone +
                    "&uemail=" + uemail +
                    "&upassword=" + upassword, function (str) {
                        if (str == "" ||str==null) {
                            window.confirm("用户名或密码错误")
                        } else {
                            window.location.replace("index.jsp")
                        }
                    })
            } else {
                window.confirm("用户名/邮箱/手机号/密码 不能为空")
            }

        })
    })
</script>
</html>
